package com.gitee.luosl.cola.match.cases;

import com.gitee.luosl.cola.util.Try;

/**
 * Created by luosl on 2021/03/31/14:06
 */
public interface ICase<T, U, R> {

    R apply(U value);

    U unapply(T value);

    default Try<R> collect(T value){
        return Try.of(() -> apply(unapply(value)));
    }

    boolean isDefinedAt(T value);

}
